/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.ucase.investigateevidence.controller;

import com.icinfo.cloud.common.core.Validator.BaseGroup;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.dto.AppraisalReportRequest;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.dto.AppraisalReportUserRequest;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.dto.CaseDocumentAppraisalYjgzsDto;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.service.ICaseDocumentAppraisalYjgzsService;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.vo.AppraisalReportInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述: 鉴定意见告知书 case_document_appraisal_yjgzs 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年04月25日
 */
@RestController
@RequestMapping("/punish/ucase/case/investigate/appraisalyjgzs")
public class CaseDocumentAppraisalYjgzsController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseDocumentAppraisalYjgzsController.class);

    @Autowired
    private ICaseDocumentAppraisalYjgzsService caseDocumentAppraisalYjgzsService;

    /**
     * 【V1.1】描述：获取状态为已完成且未生成过鉴定意见告知书的鉴定报告
     * @author liyafeng
     * @date 2022/4/25
      * @param request
     * @return {@link Result<AppraisalReportInfoVo>}
     */
    @PostMapping(value = "/getAppraisalReportInfo",produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<List<AppraisalReportInfoVo>> getAppraisalReportInfo(@RequestBody @Validated(BaseGroup.Query.class) AppraisalReportRequest request){
        List<AppraisalReportInfoVo> appraisalReportInfoVos=caseDocumentAppraisalYjgzsService.getAppraisalReportInfo(request);
        return Result.success(appraisalReportInfoVos);
    }

    /**
     * 【V1.0.0】描述：保存鉴定报告数据并生成鉴定意见告知书
     * @author liyafeng
     * @date 2022/2/17
     * @param caseDocumentAppraisalYjgzsDto
     * @return {@link Result< String>}
     */
    @PostMapping(value = "/saveAppraisalReportInfo",produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<String> saveAppraisalReportInfo(@RequestBody CaseDocumentAppraisalYjgzsDto caseDocumentAppraisalYjgzsDto){
        int num=caseDocumentAppraisalYjgzsService.saveAppraisalReportInfo(caseDocumentAppraisalYjgzsDto);

        if(num>0){
            return Result.success("保存成功");
        }
        return Result.error("保存失败");
    }
    /**
     * 【V1.1】描述：根据用户获取未生成鉴定意见告知书列表
     * @author liyafeng
     * @date 2022/5/5
     * @param request
     * @return {@link Result< List< AppraisalReportInfoVo>>}
     */
    @PostMapping(value = "/getAppraisalReportInfoByUserId",produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<List<AppraisalReportInfoVo>>  getAppraisalReportInfoByUserId(@RequestBody @Validated(BaseGroup.Query.class) AppraisalReportUserRequest request){
        List<AppraisalReportInfoVo> appraisalReportInfoVos=caseDocumentAppraisalYjgzsService.getAppraisalReportInfoByUserId(request.getUserId());
        return Result.success(appraisalReportInfoVos);
    }
}